﻿
using Minecraft.Config.Csv.CsvCls;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace Minecraft.Config
{
	/// <summary>
	/// Csv配置
	/// </summary>
	public partial class CsvConfig
	{
		//public static List<Mod_Achieve> achieveList = new List<Mod_Achieve>();
		//public static List<Mod_Actor> actorList = new List<Mod_Actor>();
		//public static List<Mod_Attribute> attributeList = new List<Mod_Attribute>();
		//public static List<Mod_Behavior> behaviorList = new List<Mod_Behavior>();
		//public static List<Mod_Biome> biomeList = new List<Mod_Biome>();
		//public static List<Mod_Block> blockList = new List<Mod_Block>();
		//public static List<Mod_BlockState> blockstateList = new List<Mod_BlockState>();
		//public static List<Mod_Blueprint> blueprintList = new List<Mod_Blueprint>();
		//public static List<Mod_Buff> buffList = new List<Mod_Buff>();
		//public static List<Mod_Compositing> compositingList = new List<Mod_Compositing>();
		//public static List<Mod_Drawing> drawingList = new List<Mod_Drawing>();
		//public static List<Mod_Drop> dropList = new List<Mod_Drop>();
		//public static List<Mod_EditorPrefab> editorprefabList = new List<Mod_EditorPrefab>();
		//public static List<Mod_Generator> generatorList = new List<Mod_Generator>();
		//public static List<Mod_Items> itemsList = new List<Mod_Items>();
		//public static List<Mod_Level> levelList = new List<Mod_Level>();
		//public static List<Mod_Map> mapList = new List<Mod_Map>();
		//public static List<Mod_MapResource> mapresourceList = new List<Mod_MapResource>();
		//public static List<Mod_MarkPoint> markpointList = new List<Mod_MarkPoint>();
		//public static List<Mod_OrganismAI> organismaiList = new List<Mod_OrganismAI>();
		//public static List<Mod_Player_Parts> player_partsList = new List<Mod_Player_Parts>();
		//public static List<Mod_RandomWorld> randomworldList = new List<Mod_RandomWorld>();
		//public static List<Mod_Tag> tagList = new List<Mod_Tag>();
		//public static List<Mod_ZombieAttack> zombieattackList = new List<Mod_ZombieAttack>();

		private static Dictionary<string, Mod_Achieve> achieveDict = new Dictionary<string, Mod_Achieve>();
		private static Dictionary<string, Mod_Actor> actorDict = new Dictionary<string, Mod_Actor>();
		private static Dictionary<string, Mod_Attribute> attributeDict = new Dictionary<string, Mod_Attribute>();
		private static Dictionary<string, Mod_Behavior> behaviorDict = new Dictionary<string, Mod_Behavior>();
		private static Dictionary<string, Mod_Biome> biomeDict = new Dictionary<string, Mod_Biome>();
		private static Dictionary<string, Mod_Block> blockDict = new Dictionary<string, Mod_Block>();
		private static Dictionary<string, Mod_BlockState> blockstateDict = new Dictionary<string, Mod_BlockState>();
		private static Dictionary<string, Mod_Blueprint> blueprintDict = new Dictionary<string, Mod_Blueprint>();
		private static Dictionary<string, Mod_Buff> buffDict = new Dictionary<string, Mod_Buff>();
		private static Dictionary<string, Mod_Compositing> compositingDict = new Dictionary<string, Mod_Compositing>();
		private static Dictionary<string, Mod_Drawing> drawingDict = new Dictionary<string, Mod_Drawing>();
		private static Dictionary<string, Mod_Drop> dropDict = new Dictionary<string, Mod_Drop>();
		private static Dictionary<string, Mod_EditorPrefab> editorprefabDict = new Dictionary<string, Mod_EditorPrefab>();
		private static Dictionary<string, Mod_Generator> generatorDict = new Dictionary<string, Mod_Generator>();
		private static Dictionary<string, Mod_Items> itemsDict = new Dictionary<string, Mod_Items>();
		private static Dictionary<string, Mod_Level> levelDict = new Dictionary<string, Mod_Level>();
		private static Dictionary<string, Mod_Map> mapDict = new Dictionary<string, Mod_Map>();
		private static Dictionary<string, Mod_MapResource> mapresourceDict = new Dictionary<string, Mod_MapResource>();
		private static Dictionary<string, Mod_MarkPoint> markpointDict = new Dictionary<string, Mod_MarkPoint>();
		private static Dictionary<string, Mod_OrganismAI> organismaiDict = new Dictionary<string, Mod_OrganismAI>();
		private static Dictionary<string, Mod_Player_Parts> player_partsDict = new Dictionary<string, Mod_Player_Parts>();
		private static Dictionary<string, Mod_RandomWorld> randomworldDict = new Dictionary<string, Mod_RandomWorld>();
		private static Dictionary<string, Mod_Tag> tagDict = new Dictionary<string, Mod_Tag>();
		private static Dictionary<string, Mod_ZombieAttack> zombieattackDict = new Dictionary<string, Mod_ZombieAttack>();

		public static Dictionary<string, Mod_Achieve> GetachieveDict()
		{
			return achieveDict;
		}
		public static Dictionary<string, Mod_Actor> GetactorDict()
		{
			return actorDict;
		}
		public static Dictionary<string, Mod_Attribute> GetattributeDict()
		{
			return attributeDict;
		}
		public static Dictionary<string, Mod_Behavior> GetbehaviorDict()
		{
			return behaviorDict;
		}
		public static Dictionary<string, Mod_Biome> GetbiomeDict()
		{
			return biomeDict;
		}
		public static Dictionary<string, Mod_Block> GetblockDict()
		{
			return blockDict;
		}
		public static Dictionary<string, Mod_BlockState> GetblockstateDict()
		{
			return blockstateDict;
		}
		public static Dictionary<string, Mod_Blueprint> GetblueprintDict()
		{
			return blueprintDict;
		}
		public static Dictionary<string, Mod_Buff> GetbuffDict()
		{
			return buffDict;
		}
		public static Dictionary<string, Mod_Compositing> GetcompositingDict()
		{
			return compositingDict;
		}
		public static Dictionary<string, Mod_Drawing> GetdrawingDict()
		{
			return drawingDict;
		}
		public static Dictionary<string, Mod_Drop> GetdropDict()
		{
			return dropDict;
		}
		public static Dictionary<string, Mod_EditorPrefab> GeteditorprefabDict()
		{
			return editorprefabDict;
		}
		public static Dictionary<string, Mod_Generator> GetgeneratorDict()
		{
			return generatorDict;
		}
		public static Dictionary<string, Mod_Items> GetitemsDict()
		{
			return itemsDict;
		}
		public static Dictionary<string, Mod_Level> GetlevelDict()
		{
			return levelDict;
		}
		public static Dictionary<string, Mod_Map> GetmapDict()
		{
			return mapDict;
		}
		public static Dictionary<string, Mod_MapResource> GetmapresourceDict()
		{
			return mapresourceDict;
		}
		public static Dictionary<string, Mod_MarkPoint> GetmarkpointDict()
		{
			return markpointDict;
		}
		public static Dictionary<string, Mod_OrganismAI> GetorganismaiDict()
		{
			return organismaiDict;
		}
		public static Dictionary<string, Mod_Player_Parts> Getplayer_partsDict()
		{
			return player_partsDict;
		}
		public static Dictionary<string, Mod_RandomWorld> GetrandomworldDict()
		{
			return randomworldDict;
		}
		public static Dictionary<string, Mod_Tag> GettagDict()
		{
			return tagDict;
		}
		public static Dictionary<string, Mod_ZombieAttack> GetzombieattackDict()
		{
			return zombieattackDict;
		}

		public static Mod_Achieve GetMod_AchieveInfoById(string id)
		{
			achieveDict.TryGetValue(id, out Mod_Achieve obj);
			return obj;
		}
		public static Mod_Actor GetMod_ActorInfoById(string id)
		{
			actorDict.TryGetValue(id, out Mod_Actor obj);
			return obj;
		}
		public static Mod_Attribute GetMod_AttributeInfoById(string id)
		{
			attributeDict.TryGetValue(id, out Mod_Attribute obj);
			return obj;
		}
		public static Mod_Behavior GetMod_BehaviorInfoById(string id)
		{
			behaviorDict.TryGetValue(id, out Mod_Behavior obj);
			return obj;
		}
		public static Mod_Biome GetMod_BiomeInfoById(string id)
		{
			biomeDict.TryGetValue(id, out Mod_Biome obj);
			return obj;
		}
		public static Mod_Block GetMod_BlockInfoById(string id)
		{
			blockDict.TryGetValue(id, out Mod_Block obj);
			return obj;
		}
		public static Mod_BlockState GetMod_BlockStateInfoById(string id)
		{
			blockstateDict.TryGetValue(id, out Mod_BlockState obj);
			return obj;
		}
		public static Mod_Blueprint GetMod_BlueprintInfoById(string id)
		{
			blueprintDict.TryGetValue(id, out Mod_Blueprint obj);
			return obj;
		}
		public static Mod_Buff GetMod_BuffInfoById(string id)
		{
			buffDict.TryGetValue(id, out Mod_Buff obj);
			return obj;
		}
		public static Mod_Compositing GetMod_CompositingInfoById(string id)
		{
			compositingDict.TryGetValue(id, out Mod_Compositing obj);
			return obj;
		}
		public static Mod_Drawing GetMod_DrawingInfoById(string id)
		{
			drawingDict.TryGetValue(id, out Mod_Drawing obj);
			return obj;
		}
		public static Mod_Drop GetMod_DropInfoById(string id)
		{
			dropDict.TryGetValue(id, out Mod_Drop obj);
			return obj;
		}
		public static Mod_EditorPrefab GetMod_EditorPrefabInfoById(string id)
		{
			editorprefabDict.TryGetValue(id, out Mod_EditorPrefab obj);
			return obj;
		}
		public static Mod_Generator GetMod_GeneratorInfoById(string id)
		{
			generatorDict.TryGetValue(id, out Mod_Generator obj);
			return obj;
		}
		public static Mod_Items GetMod_ItemsInfoById(string id)
		{
			itemsDict.TryGetValue(id, out Mod_Items obj);
			return obj;
		}
		public static Mod_Level GetMod_LevelInfoById(string id)
		{
			levelDict.TryGetValue(id, out Mod_Level obj);
			return obj;
		}
		public static Mod_Map GetMod_MapInfoById(string id)
		{
			mapDict.TryGetValue(id, out Mod_Map obj);
			return obj;
		}
		public static Mod_MapResource GetMod_MapResourceInfoById(string id)
		{
			mapresourceDict.TryGetValue(id, out Mod_MapResource obj);
			return obj;
		}
		public static Mod_MarkPoint GetMod_MarkPointInfoById(string id)
		{
			markpointDict.TryGetValue(id, out Mod_MarkPoint obj);
			return obj;
		}
		public static Mod_OrganismAI GetMod_OrganismAIInfoById(string id)
		{
			organismaiDict.TryGetValue(id, out Mod_OrganismAI obj);
			return obj;
		}
		public static Mod_Player_Parts GetMod_Player_PartsInfoById(string id)
		{
			player_partsDict.TryGetValue(id, out Mod_Player_Parts obj);
			return obj;
		}
		public static Mod_RandomWorld GetMod_RandomWorldInfoById(string id)
		{
			randomworldDict.TryGetValue(id, out Mod_RandomWorld obj);
			return obj;
		}
		public static Mod_Tag GetMod_TagInfoById(string id)
		{
			tagDict.TryGetValue(id, out Mod_Tag obj);
			return obj;
		}
		public static Mod_ZombieAttack GetMod_ZombieAttackInfoById(string id)
		{
			zombieattackDict.TryGetValue(id, out Mod_ZombieAttack obj);
			return obj;
		}

		/// <summary>
		/// csv配置文件所在目录
		/// </summary>
		public static string Folder
		{
			get
			{
				return Path.Combine("Csv", "CsvFile");
			}
		}
		/// <summary>
		/// Csv安装
		/// </summary>
		public static void Install()
		{
			List<CsvHelper.CsvInstallInfo> installInfoList = new List<CsvHelper.CsvInstallInfo>();

			//CsvHelper.InstallList(Path.Combine(Folder, "Mod_Achieve.csv"), out achieveList, installInfoList);
			//CsvHelper.InstallList(Path.Combine(Folder, "Mod_Actor.csv"), out actorList, installInfoList);
			//CsvHelper.InstallList(Path.Combine(Folder, "Mod_Attribute.csv"), out attributeList, installInfoList);
			//CsvHelper.InstallList(Path.Combine(Folder, "Mod_Behavior.csv"), out behaviorList, installInfoList);
			//CsvHelper.InstallList(Path.Combine(Folder, "Mod_Biome.csv"), out biomeList, installInfoList);
			//CsvHelper.InstallList(Path.Combine(Folder, "Mod_Block.csv"), out blockList, installInfoList);
			//CsvHelper.InstallList(Path.Combine(Folder, "Mod_BlockState.csv"), out blockstateList, installInfoList);
			//CsvHelper.InstallList(Path.Combine(Folder, "Mod_Blueprint.csv"), out blueprintList, installInfoList);
			//CsvHelper.InstallList(Path.Combine(Folder, "Mod_Buff.csv"), out buffList, installInfoList);
			//CsvHelper.InstallList(Path.Combine(Folder, "Mod_Compositing.csv"), out compositingList, installInfoList);
			//CsvHelper.InstallList(Path.Combine(Folder, "Mod_Drawing.csv"), out drawingList, installInfoList);
			//CsvHelper.InstallList(Path.Combine(Folder, "Mod_Drop.csv"), out dropList, installInfoList);
			//CsvHelper.InstallList(Path.Combine(Folder, "Mod_EditorPrefab.csv"), out editorprefabList, installInfoList);
			//CsvHelper.InstallList(Path.Combine(Folder, "Mod_Generator.csv"), out generatorList, installInfoList);
			//CsvHelper.InstallList(Path.Combine(Folder, "Mod_Items.csv"), out itemsList, installInfoList);
			//CsvHelper.InstallList(Path.Combine(Folder, "Mod_Level.csv"), out levelList, installInfoList);
			//CsvHelper.InstallList(Path.Combine(Folder, "Mod_Map.csv"), out mapList, installInfoList);
			//CsvHelper.InstallList(Path.Combine(Folder, "Mod_MapResource.csv"), out mapresourceList, installInfoList);
			//CsvHelper.InstallList(Path.Combine(Folder, "Mod_MarkPoint.csv"), out markpointList, installInfoList);
			//CsvHelper.InstallList(Path.Combine(Folder, "Mod_OrganismAI.csv"), out organismaiList, installInfoList);
			//CsvHelper.InstallList(Path.Combine(Folder, "Mod_Player_Parts.csv"), out player_partsList, installInfoList);
			//CsvHelper.InstallList(Path.Combine(Folder, "Mod_RandomWorld.csv"), out randomworldList, installInfoList);
			//CsvHelper.InstallList(Path.Combine(Folder, "Mod_Tag.csv"), out tagList, installInfoList);
			//CsvHelper.InstallList(Path.Combine(Folder, "Mod_ZombieAttack.csv"), out zombieattackList, installInfoList);

			CsvHelper.InstallDict(Path.Combine(Folder, "Mod_Achieve.csv"), out achieveDict, installInfoList);
			CsvHelper.InstallDict(Path.Combine(Folder, "Mod_Actor.csv"), out actorDict, installInfoList);
			CsvHelper.InstallDict(Path.Combine(Folder, "Mod_Attribute.csv"), out attributeDict, installInfoList);
			CsvHelper.InstallDict(Path.Combine(Folder, "Mod_Behavior.csv"), out behaviorDict, installInfoList);
			CsvHelper.InstallDict(Path.Combine(Folder, "Mod_Biome.csv"), out biomeDict, installInfoList);
			CsvHelper.InstallDict(Path.Combine(Folder, "Mod_Block.csv"), out blockDict, installInfoList);
			CsvHelper.InstallDict(Path.Combine(Folder, "Mod_BlockState.csv"), out blockstateDict, installInfoList);
			CsvHelper.InstallDict(Path.Combine(Folder, "Mod_Blueprint.csv"), out blueprintDict, installInfoList);
			CsvHelper.InstallDict(Path.Combine(Folder, "Mod_Buff.csv"), out buffDict, installInfoList);
			CsvHelper.InstallDict(Path.Combine(Folder, "Mod_Compositing.csv"), out compositingDict, installInfoList);
			CsvHelper.InstallDict(Path.Combine(Folder, "Mod_Drawing.csv"), out drawingDict, installInfoList);
			CsvHelper.InstallDict(Path.Combine(Folder, "Mod_Drop.csv"), out dropDict, installInfoList);
			CsvHelper.InstallDict(Path.Combine(Folder, "Mod_EditorPrefab.csv"), out editorprefabDict, installInfoList);
			CsvHelper.InstallDict(Path.Combine(Folder, "Mod_Generator.csv"), out generatorDict, installInfoList);
			CsvHelper.InstallDict(Path.Combine(Folder, "Mod_Items.csv"), out itemsDict, installInfoList);
			CsvHelper.InstallDict(Path.Combine(Folder, "Mod_Level.csv"), out levelDict, installInfoList);
			CsvHelper.InstallDict(Path.Combine(Folder, "Mod_Map.csv"), out mapDict, installInfoList);
			CsvHelper.InstallDict(Path.Combine(Folder, "Mod_MapResource.csv"), out mapresourceDict, installInfoList);
			CsvHelper.InstallDict(Path.Combine(Folder, "Mod_MarkPoint.csv"), out markpointDict, installInfoList);
			CsvHelper.InstallDict(Path.Combine(Folder, "Mod_OrganismAI.csv"), out organismaiDict, installInfoList);
			CsvHelper.InstallDict(Path.Combine(Folder, "Mod_Player_Parts.csv"), out player_partsDict, installInfoList);
			CsvHelper.InstallDict(Path.Combine(Folder, "Mod_RandomWorld.csv"), out randomworldDict, installInfoList);
			CsvHelper.InstallDict(Path.Combine(Folder, "Mod_Tag.csv"), out tagDict, installInfoList);
			CsvHelper.InstallDict(Path.Combine(Folder, "Mod_ZombieAttack.csv"), out zombieattackDict, installInfoList);

			if (installInfoList.Any())
			{
				installInfoList.ForEach(item =>
				{
					if (JsonConfig.Value.IsConsoleWrite)
					{
						Console.ForegroundColor = ConsoleColor.Black;
						Console.BackgroundColor = ConsoleColor.White;
						Console.WriteLine();
						//只是粗略的判断
						Console.WriteLine($" ▲▲▲▲▲▲  csv安装失败：{item.Filepath}，请更新配置文件和Model类");
						Console.ResetColor();
					}
				});
			}
			InstallAfter();
		}
	}
}
